<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            我的任务
        </div>
    </header>

    <script id="exceptionTaskTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="goPage('{{= it[index].nodeStatus }}','{{= it[index].sysid }}','{{= it[index].taskId }}','{{= it[index].exceptionTypeGid }}','{{= it[index].exceptionTypeName }}','{{= it[index].opCode }}','{{= it[index].mrlCode }}','{{= it[index].exceptionContentName }}','{{= it[index].exceptionRemark }}','{{= it[index].equipCode }}','{{= it[index].lineCode }}');">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-inner ">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            异常类型:{{= it[index].exceptionTypeName }}
                        </div>
                    </div>
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            任务节点:{{= it[index].nodeStatus }}
                        </div>
                    </div>
                    <div class="aui-list-item-text aui-font-size-14">
                        发起时间:{{= it[index].launchDate }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        产线编码:{{= it[index].lineCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        工序编码:{{= it[index].opCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        设备编码:{{= it[index].equipCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        物料编码:{{= it[index].mrlCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        异常内容:{{= it[index].exceptionContentName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        异常描述:{{= it[index].exceptionRemark }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        异常类型id:{{= it[index].exceptionTypeGid }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        sysid:{{= it[index].sysid }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-14" style="display:none">
                        taskId:{{= it[index].taskId }}
                    </div>
                </div>
            </div>
        </li>
        {{~}}

    </script>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form action="javascript:doSearch();">
                        <input type="search" placeholder="请输入任务节点" id="nodeStatus">
                    </form>
                </div>
                <i class="aui-iconfont aui-icon-roundclosefill" tapmode onclick="clearInput()"></i>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="doSearch()">搜索</div>
        </div>
    </div>

    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="exceptionTaskList">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {

        doSearch();
    };

    //查询所有任务节点
    function doSearch() {

        //任务节点
        var nodeStatus = $("#nodeStatus").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getExceptionTask";
        var data = {
            values: {
                nodeStatus: nodeStatus,
                un: un,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);

                    var evaluation = doT.template($api.dom('#exceptionTaskTemp').innerHTML);
                    $api.dom('#exceptionTaskList').innerHTML = evaluation(list);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });
    }

    //选则返回函数
    function goPage(nodeStatus, sysid, taskId, exceptionTypeGid, exceptionTypeName, opCode, mrlCode, exceptionContentName, exceptionRemark,equipCode,lineCode) {
        var name = "";
        if (nodeStatus == "待响应") {
            name = "usmExceptionResponse";
        } else if (nodeStatus == "待处理") {
            name = "usmExceptionHandling";
        } else if (nodeStatus == "待关闭") {
            name = "usmExceptionClose";
        } else if (nodeStatus == "待确认关闭") {
            name = "usmExceptionConfirmClose";
        }

        //打开页面
        api.openWin({
            name: name,
            url: name + '.html',
            pageParam: {
                name: "usmExceptionTask",
                sysid: sysid,
                taskId: taskId,
                exceptionTypeGid: exceptionTypeGid,
                exceptionTypeName: exceptionTypeName,
                opCode: opCode,
                mrlCode: mrlCode,
                exceptionContentName: exceptionContentName,
                exceptionRemark: exceptionRemark,
                equipCode:equipCode,
                lineCode:lineCode,
            }
        });
    }

    //清空
    function clearInput() {
        $api.val($api.byId("nodeStatus"), '');
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
